package com.alan.hive;

import java.sql.*;

/**
 * Created by Alan on 2017/10/5.
 */
public class HiveTest {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        Class.forName("org.apache.hive.jdbc.HiveDriver");
        Connection conn = DriverManager.getConnection("jdbc:hive2://node1/default","root","");
        try {
            Statement st = conn.createStatement();
            ResultSet ret = st.executeQuery("select count(*) from t_emp");
            if(ret.next()){
                System.out.println(ret.getInt(1));
            }
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            conn.close();
        }

    }
}
